﻿#include <QApplication>
#include "maindialog.h"
#include <QDebug>
#include <QFontDatabase>
#include <QMessageBox>
#include <QStyleFactory>

void AddFont()
{
    QString font = QApplication::applicationDirPath().append("\\fonts\\Oswald-Bold.ttf");
    int nFontID = QFontDatabase::addApplicationFont(font);
    qDebug() << __FUNCTION__ << ": nFontID=" << nFontID << ", fontname=" << QFontDatabase::applicationFontFamilies(nFontID).at(0);
}

int main(int argc, char *argv[])
{
    qDebug() << " main running ...";
    QApplication a(argc, argv);
    HANDLE hMutex = CreateMutex(NULL, TRUE, TEXT("CAC256C80AEDA97153B8A8039A3759CF"));
    if (hMutex != NULL)
    {
        if (ERROR_ALREADY_EXISTS == GetLastError())
        {
            QMessageBox::information(NULL, "提示","时钟屏保进程已存在", QMessageBox::Ok);
            CloseHandle(hMutex);
            return 0;
        }
    }

    a.setQuitOnLastWindowClosed(false);
    a.setStyle(QStyleFactory::create("fusion"));
    AddFont();
    MainDialog w;
    w.show();
    return a.exec();
}
